/*
 *  ChordTester.cpp
 *  SoundController0002
 *
 *  Created by jiro on 11/06/12.
 *  Copyright 2011 jiro music. All rights reserved.
 *
 */

#include "ChordListTester.h"

#include "../ChordList.h"
#include "../../../sc/Tester/CustomAssert.h"
#include "../../../sc/AllExceptions.h"

namespace sc
{
namespace hs
{

	void ChordListTester::TestAll()
	{
		try
		{
//			FindChordsIncludeHarmonics000();
//
//			FindChordsIncludeHarmonics001();
//
//			IsExistChordsIncludeHarmonics000();
//
//			IsExistChordsIncludeHarmonics001();
		}
		catch ( NotImplementedException& e )
		{
			cout << e.what() << endl;
		}
	}
	
	void ChordListTester::FindChordsIncludeHarmonics000()
	{
		throw NotImplementedException( "void ChordListTester::FindChordsIncludeHarmonics000()" );
	/*
		ChordList chordList;
		Chord chord;
		double freqs0[] = { 100, 101, 200 };
		double freqs1[] = { 101, 102, 202 };
		double freqs2[] = { 102, 103, 203 };
		
		for ( int i = 0; i < sizeof( freqs0 ) / sizeof( double ); i++ )
		{
			chord.push_back( Sound( Wave::SawWave, freqs0[ i ] ) );
		}
		chordList.push_back( chord );
		chord.clear();

		for ( int i = 0; i < sizeof( freqs1 ) / sizeof( double ); i++ )
		{
			chord.push_back( Sound( Wave::SawWave, freqs1[ i ] ) );
		}
		chordList.push_back( chord );
		chord.clear();

		for ( int i = 0; i < sizeof( freqs2 ) / sizeof( double ); i++ )
		{
			chord.push_back( Sound( Wave::SawWave, freqs2[ i ] ) );
		}
		chordList.push_back( chord );
		chord.clear();

		ChordList chordListOut;

		AssertEqual( chordList.FindChordsIncludeHarmonics( 99, chordListOut ), false );
		AssertEqual( chordListOut.size(), 0 );
		chordListOut.clear();

		AssertEqual( chordList.FindChordsIncludeHarmonics( 100, chordListOut ), true );
		AssertEqual( chordListOut.size(), 1 );
		AssertEqual( chordListOut[ 0 ][ 0 ].GetFrequency(), 100 );
		AssertEqual( chordListOut[ 0 ][ 1 ].GetFrequency(), 101 );
		AssertEqual( chordListOut[ 0 ][ 2 ].GetFrequency(), 200 );
		chordListOut.clear();

		AssertEqual( chordList.FindChordsIncludeHarmonics( 202, chordListOut ), true );
		AssertEqual( chordListOut.size(), 2 );
		AssertEqual( chordListOut[ 0 ][ 0 ].GetFrequency(), 100 );
		AssertEqual( chordListOut[ 0 ][ 1 ].GetFrequency(), 101 );
		AssertEqual( chordListOut[ 0 ][ 2 ].GetFrequency(), 200 );
		AssertEqual( chordListOut[ 1 ][ 0 ].GetFrequency(), 101 );
		AssertEqual( chordListOut[ 1 ][ 1 ].GetFrequency(), 102 );
		AssertEqual( chordListOut[ 1 ][ 2 ].GetFrequency(), 202 );
		chordListOut.clear();
		*/
	}

	void ChordListTester::FindChordsIncludeHarmonics001()
	{
		throw NotImplementedException( "void ChordListTester::FindChordsIncludeHarmonics001()" );
	/*
		ChordList chordList;
		Chord chord;
		double freqs0[] = { 100, 101, 200 };
		double freqs1[] = { 101, 102, 202 };
		double freqs2[] = { 102, 103, 203 };
		
		for ( int i = 0; i < sizeof( freqs0 ) / sizeof( double ); i++ )
		{
			chord.push_back( Sound( Wave::SawWave, freqs0[ i ] ) );
		}
		chordList.push_back( chord );
		chord.clear();

		for ( int i = 0; i < sizeof( freqs1 ) / sizeof( double ); i++ )
		{
			chord.push_back( Sound( Wave::SawWave, freqs1[ i ] ) );
		}
		chordList.push_back( chord );
		chord.clear();

		for ( int i = 0; i < sizeof( freqs2 ) / sizeof( double ); i++ )
		{
			chord.push_back( Sound( Wave::SawWave, freqs2[ i ] ) );
		}
		chordList.push_back( chord );
		chord.clear();

		ChordList chordListOut;

		AssertEqual( chordList.FindChordsIncludeHarmonics( 99, 100 - 0.0001, chordListOut ), false );
		AssertEqual( chordListOut.size(), 0 );
		chordListOut.clear();

		AssertEqual( chordList.FindChordsIncludeHarmonics( 100, 101, chordListOut ), true );
		AssertEqual( chordListOut.size(), 2 );
		AssertEqual( chordListOut[ 0 ][ 0 ].GetFrequency(), 100 );
		AssertEqual( chordListOut[ 0 ][ 1 ].GetFrequency(), 101 );
		AssertEqual( chordListOut[ 0 ][ 2 ].GetFrequency(), 200 );
		AssertEqual( chordListOut[ 1 ][ 0 ].GetFrequency(), 101 );
		AssertEqual( chordListOut[ 1 ][ 1 ].GetFrequency(), 102 );
		AssertEqual( chordListOut[ 1 ][ 2 ].GetFrequency(), 202 );
		chordListOut.clear();

		AssertEqual( chordList.FindChordsIncludeHarmonics( 203.5, 204, chordListOut ), true );
		AssertEqual( chordListOut.size(), 2 );
		AssertEqual( chordListOut[ 0 ][ 0 ].GetFrequency(), 101 );
		AssertEqual( chordListOut[ 0 ][ 1 ].GetFrequency(), 102 );
		AssertEqual( chordListOut[ 0 ][ 2 ].GetFrequency(), 202 );
		AssertEqual( chordListOut[ 1 ][ 0 ].GetFrequency(), 102 );
		AssertEqual( chordListOut[ 1 ][ 1 ].GetFrequency(), 103 );
		AssertEqual( chordListOut[ 1 ][ 2 ].GetFrequency(), 203 );
		chordListOut.clear();
*/
	}

	void ChordListTester::IsExistChordsIncludeHarmonics000()
	{
		throw NotImplementedException( "void ChordListTester::IsExistChordsIncludeHarmonics000()" );
	/*
		ChordList chordList;
		Chord chord;
		double freqs0[] = { 100, 101, 200 };
		double freqs1[] = { 101, 102, 202 };
		double freqs2[] = { 102, 103, 203 };
		
		for ( int i = 0; i < sizeof( freqs0 ) / sizeof( double ); i++ )
		{
			chord.push_back( Sound( Wave::SawWave, freqs0[ i ] ) );
		}
		chordList.push_back( chord );
		chord.clear();

		for ( int i = 0; i < sizeof( freqs1 ) / sizeof( double ); i++ )
		{
			chord.push_back( Sound( Wave::SawWave, freqs1[ i ] ) );
		}
		chordList.push_back( chord );
		chord.clear();

		for ( int i = 0; i < sizeof( freqs2 ) / sizeof( double ); i++ )
		{
			chord.push_back( Sound( Wave::SawWave, freqs2[ i ] ) );
		}
		chordList.push_back( chord );
		chord.clear();

		ChordList chordListOut;

		AssertEqual( chordList.IsExistChordsIncludeHarmonics( 99 ), false );
		AssertEqual( chordList.IsExistChordsIncludeHarmonics( 100 ), true );
		AssertEqual( chordList.IsExistChordsIncludeHarmonics( 202 ), true );
		*/
	}

	void ChordListTester::IsExistChordsIncludeHarmonics001()
	{
		throw NotImplementedException( "void ChordListTester::IsExistChordsIncludeHarmonics001()" );
	/*
		ChordList chordList;
		Chord chord;
		double freqs0[] = { 100, 101, 200 };
		double freqs1[] = { 101, 102, 202 };
		double freqs2[] = { 102, 103, 203 };
		
		for ( int i = 0; i < sizeof( freqs0 ) / sizeof( double ); i++ )
		{
			chord.push_back( Sound( Wave::SawWave, freqs0[ i ] ) );
		}
		chordList.push_back( chord );
		chord.clear();

		for ( int i = 0; i < sizeof( freqs1 ) / sizeof( double ); i++ )
		{
			chord.push_back( Sound( Wave::SawWave, freqs1[ i ] ) );
		}
		chordList.push_back( chord );
		chord.clear();

		for ( int i = 0; i < sizeof( freqs2 ) / sizeof( double ); i++ )
		{
			chord.push_back( Sound( Wave::SawWave, freqs2[ i ] ) );
		}
		chordList.push_back( chord );
		chord.clear();

		ChordList chordListOut;

		AssertEqual( chordList.IsExistChordsIncludeHarmonics( 99, 100 - 0.0001 ), false );
		AssertEqual( chordList.IsExistChordsIncludeHarmonics( 100, 101 ), true );
		AssertEqual( chordList.IsExistChordsIncludeHarmonics( 203.5, 204 ), true );
		*/
	}

}
}